package main

import (
	"dockerRun/simple"
	"encoding/json"
	"log"
	"net/http"
)

var peoples []simple.People

func init() {
	peoples = append(peoples, simple.People{"Mike", 15})
	peoples = append(peoples, simple.People{"Jimi", 19})
	peoples = append(peoples, simple.People{"Luma", 18})
	peoples = append(peoples, simple.People{"Pop", 22})
}

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		bytes, err := json.Marshal(peoples)
		if err != nil {
			log.Printf("请求 %d %s \n", 500, r.URL)
			w.Write([]byte(err.Error()))
			return
		}
		log.Printf("请求 %d %s \n", 200, r.URL)
		w.Write([]byte(bytes))
	})
	http.ListenAndServe(":778", nil)
}
